<template>
	<view>
		<view>请选择星座</view> 
	
		<view style="display: flex;flex-wrap: wrap; box-sizing: border-box; padding: 10px;">
			<view style="flex: 1; width: 33.3%; margin-bottom: 10px; line-height: 50px; min-width: 33.3%; max-width: 25%;" v-for="(item,index) in datalist" :key="index"
			@click="xz(item)"
			>
				<image style="width: 50px; margin-right: 10px; height: 50px; vertical-align:-20px ;" :src="item.pic" mode=""></image>
				{{item.astroname}}
			</view>
		</view>
		<view v-if="data.result.astroname">
			<view style="box-sizing: border-box; padding: 10px;">
				<view>
					{{data.result.astroname}}
				</view>
				<view>
					{{data.result.week.date}}
				</view>
				<view class="">
					<view style="font-weight: bold;">总结</view>
					{{data.result.week.summary}}
				</view>
				<view>
					<view style="font-weight: bold;">
						收入
					</view>
					<view>
						{{data.result.week.money}}
					</view>
				</view>
				<view>
					<view style="font-weight: bold;">
						事业
					</view>
					<view>
						{{data.result.week.career}}
					</view>
				</view>
				<view>
					<view style="font-weight: bold;">
						爱情
					</view>
					<view>
						{{data.result.week.love}}
					</view>
				</view>
				<view>
					<view style="font-weight: bold;">
						今日运势
					</view>
					{{data.result.today.presummary}}
					<view>
						幸运色:{{data.result.today.color}}
					</view>
					<view>
						幸运数字:{{data.result.today.number}}
					</view>
					<view>
						爱情指数:{{data.result.today.love}} 
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import moke from './moke.js'
	export default {
		data() {
			return {
				data:{
					result: {}
				},
				datalist:[
				    {
				        "astroid": 1,
				        "astroname": "白羊座",
				        "date": "3-21~4-19",
				        "pic": "http://api.jisuapi.com/astro/static/images/baiyang.png"
				    },
				    {
				        "astroid": 2,
				        "astroname": "金牛座",
				        "date": "4-20~5-20",
				        "pic": "http://api.jisuapi.com/astro/static/images/jinniu.png"
				    },
				    {
				        "astroid": 3,
				        "astroname": "双子座",
				        "date": "5-21~6-21",
				        "pic": "http://api.jisuapi.com/astro/static/images/shuangzi.png"
				    },
				    {
				        "astroid": 4,
				        "astroname": "巨蟹座",
				        "date": "6-22~7-22",
				        "pic": "http://api.jisuapi.com/astro/static/images/juxie.png"
				    },
				    {
				        "astroid": 5,
				        "astroname": "狮子座",
				        "date": "7-23~8-22",
				        "pic": "http://api.jisuapi.com/astro/static/images/shizi.png"
				    },
				    {
				        "astroid": 6,
				        "astroname": "处女座",
				        "date": "8-23~9-22",
				        "pic": "http://api.jisuapi.com/astro/static/images/chunv.png"
				    },
				    {
				        "astroid": 7,
				        "astroname": "天秤座",
				        "date": "9-23~10-23",
				        "pic": "http://api.jisuapi.com/astro/static/images/tianping.png"
				    },
				    {
				        "astroid": 8,
				        "astroname": "天蝎座",
				        "date": "10-24~11-22",
				        "pic": "http://api.jisuapi.com/astro/static/images/tianxie.png"
				    },
				    {
				        "astroid": 9,
				        "astroname": "射手座",
				        "date": "11-23~12-21",
				        "pic": "http://api.jisuapi.com/astro/static/images/sheshou.png"
				    },
				    {
				        "astroid": 10,
				        "astroname": "摩羯座",
				        "date": "12-22~1-19",
				        "pic": "http://api.jisuapi.com/astro/static/images/mojie.png"
				    },
				    {
				        "astroid": 11,
				        "astroname": "水瓶座",
				        "date": "1-20~2-18",
				        "pic": "http://api.jisuapi.com/astro/static/images/shuiping.png"
				    },
				    {
				        "astroid": 12,
				        "astroname": "双鱼座",
				        "date": "2-19~3-20",
				        "pic": "http://api.jisuapi.com/astro/static/images/shuangyu.png"
				    }
				],
				info: {}
			}
		},
		methods: {
			xz(item){
				uni.showLoading({
					title: '加载中...'
				})
				let time = ''
				let date = new Date()
				let year = date.getFullYear()
				let month = date.getMonth() + 1
				if (month < 10){
					month = '0' + month
				}
				let day = date.getDate()
				if (day < 10) {
					day = '0' + day
				}
				time = `${year}-${month}-${day}`
				let appkey = '29850188b9009347'
				uni.request({
					url: `https://api.jisuapi.com/astro/fortune?astroid=${item.astroid}&date=${time}&appkey=${appkey}`,
					method: 'POST',
					success: (res) => {
						console.log(res.data.result)
						this.data = res.data
						uni.hideLoading()
					},
					fail: (err) => {
						console.log(err)
					}
				})
				// https://api.jisuapi.com/astro/fortune?astroid=1&date=2016-01-19&appkey=******
				
			}
		}
	}
</script>

<style>

</style>
